// 处理时间日期格式为 2021.07.07 11:00 格式
function formDate (data) {
  // console.log(data);
  if(data){
    const result = [];
    const now = new Date(data);
    const y = now.getFullYear();
    const m = now.getMonth() + 1 < 10 ? '0' + (now.getMonth() + 1) : now.getMonth() + 1;
    const d = now.getDate() < 10 ? '0' + now.getDate() : now.getDate();
    const years = y + '.' + m + '.' + d;
    result.push(years);
    const hours = now.getHours() < 10 ? '0' + now.getHours() : now.getHours();
    const minutes = now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes();
    const seconds = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds();
    const clock = hours + ':' + minutes + ':' + seconds
    result.push(clock);
    return result;
  }
  return []
}

// 获取具体时间差
function formatDuring (mss) {  
  var days = parseInt(Math.floor(mss / (60 * 24)));
  var hours = days > 0 ? Math.floor((mss / 60 % 24)) : Math.floor(mss / 60);
  var minutes = Math.floor(mss % 60);
  return (days <= 0) ? hours + "时" + minutes + "分" : days + "天" + hours + "时" + minutes + "分";
}

export {
  formDate,
  formatDuring
}